import React, { PureComponent } from 'react'

export class App extends PureComponent {
    constructor(){
        super()
        this.state= {
            userName:"inzv"
        }
    }
    inputChange(event){
        console.log("value",event.target.value)
        this.setState({userName:event.target.value},()=>{console.log(this.state.userName)})
    }
  render() {
    const {userName} = this.state
    return (
      <div>
        {/* 绑定value 受控组件 */}
        <input type="text" value={userName} onChange={e=> this.inputChange(e)}/>
        {/* 不受控 */}
        <input type="text" />
        <h2>userName:{userName}</h2>
      </div>
    )
  }
}

export default App